import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] trains = new int[n];
        int[] stop = new int[n];
        int i = 0;
        int ans = 0;
        while (n > 0) {
            trains[i++] = scanner.nextInt();
            n--;
        }
        i = 0;
        int m = 0;
        for (int j = 0; j < trains.length; j++) {
            if (j + 1 >= trains[i]) {
                i++;
                ans++;
            } else {
                stop[m++] = j + 1;
            }
        }
        System.out.println(ans - 1);
    }
}
